package com.wyzt.item.api;

import com.wyzt.common.vo.PageResult;
import com.wyzt.item.pojo.Brand;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("brand")
public interface BrandApi {

    /**
     * 分页查询品牌
     *
     * @param page
     * @param rows
     * @param sortBy
     * @param desc
     * @param search
     * @return
     */
    @GetMapping("page")
    public PageResult<Brand> queryBrandByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "sortBy", required = false) String sortBy,
            @RequestParam(value = "desc", defaultValue = "false") Boolean desc,
            @RequestParam(value = "search", required = false) String search
    );

    /**
     * 新增品牌
     *
     * @param brand
     * @param categories categories
     * @return
     */
    @PostMapping
    public ResponseEntity<Void> saveBrand(
            Brand brand, @RequestParam("categories") List<Long> categories);

    /**
     * 根据商品分类查询品牌
     *
     * @param cid
     * @return
     */
    @GetMapping("/cid/{cid}")
    public ResponseEntity<List<Brand>> queryBrandByCid(@PathVariable("cid") Long cid);

    /**
     * 根据id查询品牌
     *
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Brand queryBrandById(@PathVariable("id") Long id);

    @GetMapping("brands")
    public List<Brand> queryBrandByIds(@RequestParam("ids") List<Long> ids);
}
